package load.drawing;

import core.InPort;
import core.StdNode;
import core.TriggerPort;
import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author Ben
 */
public class DrawLine  extends StdNode{
    private InPort x1 = new InPort(Integer.class);
    private InPort y1 = new InPort(Integer.class);
    private InPort x2 = new InPort(Integer.class);
    private InPort y2 = new InPort(Integer.class);
    private InPort color = new InPort(Color.class);

    private TriggerPort draw = new TriggerPort() {
            @Override
            public void callInternal() {
                Graphics g = controller.StdDraw.getInstance().getGraphics();
                g.setColor((Color)color.getValue());
                g.drawLine((Integer)x1.getValue(),(Integer) y1.getValue(),
                           (Integer)x2.getValue(), (Integer)y2.getValue());
            }
    };

    public DrawLine() {
        this.autoPutPorts();
    }
}
